package com.ruoyi.project.system.config;

import org.springframework.stereotype.Component;

import java.io.FileWriter;
import java.io.IOException;

/**
 * @program: ruoyi
 * @description: 支付宝支付的相关配置类
 * @author: yanghua
 * @create: 2020-09-22 17:56
 **/
@Component
public class AlipayConfig {
    // 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号,开发时使用沙箱提供的APPID，生产环境改成自己的APPID
    public static String APP_ID = "2021002134689975";

    // 商户私钥，您的PKCS8格式RSA2私钥
    public static String APP_PRIVATE_KEY = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCrTP8jf4fR1mef99Ldm2YpVmJaYjkOtHO8MCblijro1vUj2DIgy2p8WRldgUj9TwMvXDeVZwdF7EDQ1gaGy9rqrXcLMHuq3b1s+e6Vl/B52ws3satGkN9VeqO9v92tcyouCv4l12cAnDkSemPkTAkmmllXIlvqeAJOEmbrkj1yaILgsVDjPNX0+2Mm++q9DOQ/c7ufR103qtO5QMoN+VuuyMPZKyF9gmcyZ+IRix8cuEtcRZBw3U93A6eXodjFzh8B2M2YKxUBHk3L9w7hA/AqP23TNa9z/yIj2Xqw4LBc7UbB4uSZPlRV+5GM+B0dF1j1+jRqjUcvYrT/mvt0+60hAgMBAAECggEAMFefXSY9bzOBtPxcTtvvHdVaFkXH8mVsj/xKzdaPv2wCbGYz51tgps0CQogc0Be/P1tX+FrGC66bsBPmbZ4UHsxrXwYEsHi5X4q9EQx6+fieFs6WFmkGDfp5QTBnX+6zRaEmjglW8S4lURinHiNzJajDc7qnk+jgRaYd03dGzgVGy2mu+6VSaHZEAlU2FAj7rd15UCPuC74t04BtKPO1CTOEbOdDCSRx3khssBKWgMIoclKietOjlzp59puuQPNXqDiuQfQt/Fx7MCka7KwoXLjf+jTOOk8Ka5BpumXNVSKzwjHmwcTMK5nAfKPjrhW+gBFKS6II8DsnrGms70kQAQKBgQD1wx9JwJpPPn2kjzvyvm5JdRrQOmCNBT7HfL438wmiySNJC3KfH56IFpdWIBFt92TRrf7Bxi8mfT9KkC8/ilcdPXU2QZE1ArTdH/iolTRmRzWSHXN+qSfX07uMWNWTzDYO8vOmnsMHYrYtiFZbPNe+NowimKHBpnBSIrr1PnoFgQKBgQCyb8vvgM8KPRBD0tKbjqBhXSKaSa+KkIOVnlMyGERO7VzC3vGpdrAFVDqWX3h3SICRftci29D3Qi9s4+9h3v6v/0Q0pyOgkG8fFKjimLoqr6fA16VPoTq+632u2u+VnFshpj64mwW+seJvoDExdAr/lhaLVhazDmRmjPZ7/c+3oQKBgQC6lmsB1r4RXhOMRccw9E3NbaBu6XN2fb39PQM6fUYalnU4tv1OPHZjQiuiEvTItaSQ4XZi7jHMGhlcZf3JUyHyrD96cutpAOYKYISskaNX58aPadbPGmSKo1FoK+XzsX51eRVtsmnGCLbh+Pn/iUEPRGC+v31IBjKO2ZlyKv3/gQKBgCBmZGVswitdwyJNmahdUYncW3gggRtr+jiksv6ZoW2jdAB+cusOfg+5p5m+ZCVkqNPCcFYIC/2ZqvreuIzQ7PYQJ9ZXswRotYSzP6dFjChMFO3TOlUnNX+NSxkA8Bf+eB24DhN/Mp/ZtQAH2mbcZ1LZceaDD0QcDOcCGY+SGrGBAoGAS42UO17Yw51WDmVYIn+3O8LqfLxNlDeygm0qpSvg9AJFuLpmcgRaPq3TyQ2WzydU1W3jwdNwAnCqY4PFaeCeZWrDw+XxgCpj2Bx/+Y9GAOEZro/pwjOucQW8zTGt1EMFD5xKwRsptiFwrlL7aW7my55sdXEehyRkNeQgc9TpCjM=";

    // 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。你自己的支付宝公钥，注意是支付宝公钥，不是应用公钥
    public static String ALIPAY_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAl6PsHbOZOTCH+m++I/+qaVOpzSSTCvzJIl8Stt/BTvwfuLjJm3HWWk8nzL02S0Lkef3Fjf2MwRAPLIXg1d/t4T1SbkWJ07/fwhwSLatylDkamLYbb8PziDAdkDvHYwUY208iFaRKxPPPEPnZN6S8xPJZtoS2nyYI2LUEbyXNhTOsT3AFlAYwB/QrxZta/aabeUnbn8A85DiylAeyRbRASf8LIH6JQ9us7nGwXHnO8kos47yIybcZuRChrFEysAkU7yw4AFO4lSsnJl6q2TazUmX42CwqDYip0BGiJKPOe0Te1IoIApRVftMIt03pxMjgesNiTXTugkQ8CLwM03euhQIDAQAB";

    // 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    public static String notify_url = "http://baiyun.com:7777";
    //public static String notify_url = "http://121.4.239.166:8080";

    // 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问(其实就是支付成功后返回的页面)/testpay/zfbLogin
    public static String return_url = "http://baiyun.com:7777/index";
    //public static String return_url = "http://121.4.239.166:8080/index";

    // 签名方式
    public static String sign_type = "RSA2";

    // 字符编码格式
    public static String CHARSET = "utf-8";

    // 支付宝网关，这是沙箱的网关
    //public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";//测试
    public static String gatewayUrl = "https://openapi.alipay.com/gateway.do";

    // 支付宝网关
    public static String log_path = "F:\\";

    public static final String ALIPAY_SYSTEM_OAUTH_TOKEN_RESPONSE = "alipay_user_info_share_response";


//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /**
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
